from typing import List
from datetime import datetime
from dataclasses import dataclass, asdict, fields

from ._orginal import Orginal

@dataclass(init=False)
class Details(Orginal):
    parent_model: str
    format: str
    family: str
    families: List[str]
    parameter_size: str
    quantization_level: str

    def __init__(self, orginal=None, **kwargs):
        super().setOrginal(orginal)


@dataclass(init=False)
class ModelInfo(Orginal):
    general_architecture: str
    general_base_model_0_name: str
    general_base_model_0_organization: str
    general_base_model_0_repo_url: str
    general_base_model_count: int
    general_basename: str
    general_file_type: int
    general_finetune: str
    general_languages: List[str]
    general_license: str
    general_license_link: str
    general_parameter_count: int
    general_quantization_version: int
    general_size_label: str
    general_tags: List[str]
    general_type: str
    qwen2_attention_head_count: int
    qwen2_attention_head_count_kv: int
    qwen2_attention_layer_norm_rms_epsilon: float
    qwen2_block_count: int
    qwen2_context_length: int
    qwen2_embedding_length: int
    qwen2_feed_forward_length: int
    qwen2_rope_freq_base: int
    tokenizer_ggml_add_bos_token: bool
    tokenizer_ggml_bos_token_id: int
    tokenizer_ggml_eos_token_id: int
    tokenizer_ggml_merges: None
    tokenizer_ggml_model: str
    tokenizer_ggml_padding_token_id: int
    tokenizer_ggml_pre: str
    tokenizer_ggml_token_type: None
    tokenizer_ggml_tokens: None

    def __init__(self, orginal=None, **kwargs):
        super().setOrginal(orginal)
        names = set([f.name for f in fields(self)])
        for k, v in kwargs.items():
            if k in names:
                setattr(self, k, v)

@dataclass(init=False)
class Show(Orginal):
    license: str
    modelfile: str
    template: str
    system: str
    details: Details
    model_info: ModelInfo
    modified_at: datetime

    def __init__(self, orginal=None, **kwargs):
        super().setOrginal(orginal)
        names = set([f.name for f in fields(self)])
        for k, v in kwargs.items():
            if k in names:
                setattr(self, k, v)